<?php
	$_products = $this->getProductCollection();
	$limit_length = 160;
	$_limit = $this->getLimitCount();
	$_n = $_products->getSize();
	if($_limit == "" || $_limit > $_n){
		$_limit = $_n;
	}	 
	$_title = $this->getFrontendTitle();

	$_showname = $this->showProductName();
	$_w = $this->getThumbnailWidth();
	$_h = $this->getThumbnailHeight();
	$_showthumb = $this->showThumb();
	$_columnCount = $this->getColumnCount();
    $alt_img = $this->getAltImg();
	
	$_showprice = $this->show_Price();
	$_showlabel = $this->show_Label();
	$_showCart = $this->show_AddtoCart();
	$_showAddto = $this->show_Addto();
?>
<div>
	<?php if($_title): ?>	  
		<div class="widget-title">
			<h2><span><?php echo $_title; ?></span></h2>
		</div>
	<?php endif; ?>
	
	<?php if($_limit): ?>
		<div class="widget widget-recentreview-products">
			<?php if($_title!=""): ?>
			<div class="widget-title">		  
				<h3><span><?php echo $_title; ?></span></h3>
			</div>
			<?php endif; ?>
	
			<div class="widget-products">
				<?php $i=0; foreach ($_products->getItems() as $_product): ?>
					<?php if ($_columnCount > 0 && $i%$_columnCount==0 || $_columnCount <= 0 && $i == 0): ?>
					<ul class="products-grid">
					<?php endif ?>
					<li class="<?php if($itemClass = $this->getData('item_class')) echo $itemClass.' ';?>item<?php echo $_columnCount > 0 && $i%$_columnCount==0 || $_columnCount <= 0 && $i == 0 ?' first':''; ?><?php echo $_columnCount > 0 && ($i+1)%$_columnCount==0 || $i+1 == $_limit ?' last':''; ?>"
						style="<?php echo $this->getItemWidth() ? 'width:'.$this->getItemWidth().'px;' : '' ?> <?php echo $this->getItemHeight() ? 'height:'.$this->getItemHeight().'px;' : '' ?> <?php echo $this->getItemSpacing() ? 'margin-right:'.$this->getItemSpacing().'px;margin-bottom:'.$this->getItemSpacing().'px;' : '' ?>">
								
						<?php if($_showthumb=="true"): ?>
						<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>" class="product-image">
							<?php if ($_showlabel=='true'):?>
								<!--show label product - label extension is required-->
								<?php Mage::helper('productlabels')->display($_product);?>
							<?php endif;?>
							<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($_w, $_h) ?>" width="<?php echo $_w; ?>" height="<?php echo $_h; ?>" <?php if ($alt_img): ?> 
                                rel="<?php echo $alt_img ?>" 
                                data-alt-src="<?php echo $this->helper('catalog/image')->init($_product, $alt_img)->resize($_w, $_h) ?>"
                                <?php endif ?> alt="<?php echo $this->stripTags($_product->getName(), null, true) ?>" /></a>
						<?php else:?>
							<?php if ($_showlabel=='true'):?>
								<!--show label product - label extension is required-->
								<?php Mage::helper('productlabels')->display($_product);?>
							<?php endif;?>
						<?php endif; ?>
				
						<div class="product-shop">
							<div class="f-fix">
								<?php if($_showname=="true"): ?>
									<h3 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>)"><?php echo $this->helper('catalog/output')->productAttribute($_product, $_product->getName() , 'name') ?></a></h3>
								<?php endif; ?>
						
								<?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
						
								<?php if($_showprice=="true"): ?>
									<?php echo $this->getPriceHtml($_product, true, '-widget-new-list') ?>
								<?php endif; ?>
						
								<?php if($_showCart=="true"): ?>
									<?php if ($_product->isSaleable()): ?>
										<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
									<?php else: ?>
										<p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
									<?php endif; ?>
								<?php endif; ?>
						
								<?php if($_showAddto=="true"):?>
								<ul class="add-to-links">
									<?php if ($this->helper('wishlist')->isAllow()) : ?>
										<li><a href="<?php echo $this->getAddToWishlistUrl($_product) ?>" class="link-wishlist" title="<?php echo $this->__('Add to Wishlist') ?>"><?php echo $this->__('Add to Wishlist') ?></a></li>
									<?php endif; ?>
									<?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
										<li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare" title="<?php echo $this->__('Add to Compare') ?>"><?php echo $this->__('Add to Compare') ?></a></li>
									<?php endif; ?>
								</ul>
								<?php endif; ?>
							</div>
						</div>
					</li>
					<?php if ( $_columnCount > 0 && ($i+1)%$_columnCount==0 || $i+1==$_limit ): ?>
					</ul>
					<?php endif; ?>
					<?php $i++;?>
					<?php if ($i >= $_limit) break; ?>
				<?php endforeach; ?>
			</div>
		</div>
	<?php else:?>
		<p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
	<?php endif; ?>
</div>
<script type="text/javascript">
	decorateGeneric($$('ul.products-grid'),['last','first','odd','even']);
</script>
